package com.crm.controller;

import java.util.List;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.crm.common.ResVo;
import com.crm.entity.Thumbnail;
import com.crm.service.ThumbnailService;
import com.spring4all.swagger.EnableSwagger2Doc;

import io.swagger.annotations.Api;


@RestController
@EnableSwagger2Doc
@RequestMapping("/thumbnail")
@Api(tags = "缩略图管理")
public class ThumbnailController {

	
	@Autowired
	private ThumbnailService thumbnailService;
	
	
	@GetMapping("/getThumbnail/{photoId}")
	@ApiOperation("按图片id查询图片的详细图片的缩略图")
	public ResVo<Object> findThumbnailByPhotoId(@PathVariable @ApiParam("图片id") String photoId) {
		List<Thumbnail> message = thumbnailService.findThumbnailByPhotoId(photoId);
		return ResVo.success(message);
	}
	
	@PostMapping("/addThumbnail")
	@ApiOperation("为指定图片添加缩略图")
	public ResVo<Object> addThumbnail(@RequestBody Thumbnail thumbnail) {
		thumbnailService.addThumbnail(thumbnail);
		return ResVo.defaultSuccess();
	}
	
}
